import { fetchMessages } from '../../utils/request';

Page({
  data: {
    systemMessages: [
      { id: 1, type: '系统消息', avatarUrl: '/images/img1.jpg', sender: '物流通知', content: '您的订单正在派送中' }
    ],
    privateChats: [
      { id: 1, type: '私聊/评论回复', avatarUrl: '/images/img2.jpg', sender: '我的关注', content: '今天吧!', chatType: '关注' },
      { id: 2, type: '私聊/评论回复', avatarUrl: '/images/img3.jpg', sender: '商家', content: '好的', chatType: '商家' }
    ],
    likes: [
      { id: 1, type: '收到的赞', avatarUrl: '/images/img4.jpg', sender: '帖子1', content: '***给你点赞了' }
    ]
  },

  onReady() {
    // 初始化数据
  },

  handleOpenChat(event) {
    const item = event.currentTarget.dataset.item;
    let chatPage;

    switch(item.type) {
      case '系统消息':
        chatPage = '../chatSystemMessage/chatSystemMessage';
        break;
      case '私聊/评论回复':
        chatPage = '../chatPrivate/chatPrivate';
        break;
      case '收到的赞':
        chatPage = '../chatLikes/chatLikes';
        break;
      default:
        return;
    }

    wx.navigateTo({
      url: `${chatPage}?itemId=${item.id}&chatType=${item.chatType}`
    });
  }
});